from likeshop_api_project.api.login_api import login_model
from likeshop_api_project.base.mybase import Tools


# 支付
class get_payment_model(Tools):
    path = '/api/payment/prepay'

    def get_payment_action(self, order, order_id, order_source, hd):
        get_payment_data = {
            "from": order,
            "order_id": order_id,
            "order_source": order_source
        }
        payment = self.huihua.post(url=self.hosturl+self.path, data=get_payment_data, headers=hd)
        return payment.json()


if __name__ == '__main__':
    import requests

    s = requests.session()
    reg = login_model(huihua=s)
    msg = reg.login_action(account="13356786546", password="rr98765", client=2)
    # print(msg)
    get_token = msg["data"]["token"]
    # print(get_token)
    hd = {"token": get_token}

    payment = get_payment_model(huihua=s)
    msg = payment.get_payment_action(order="order", order_id=342, order_source=6, hd=hd)
    print(msg)
